<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Vulnerability extends Model
{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'vulnerabilities';

    /**
     * Many-to-many relationship for Assets
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function assets()
    {
        return $this->belongsToMany(Asset::class, 'assets_vulnerabilities')->withPivot('created_at');
    }

    /**
     * Many-to-many relationship for Exploits
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function exploits()
    {
        return $this->belongsToMany(Exploit::class, 'vulnerabilities_exploits')->withPivot('created_at');
    }

    /**
     * Many-to-many relationship for Files
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function files()
    {
        return $this->belongsToMany(File::class, 'files_vulnerabilities')->withPivot('created_at');
    }

    /**
     * Many-to-many relationship for Folders
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function folders()
    {
        return $this->belongsToMany(Folder::class, 'folders_vulnerabilities')->withPivot('created_at');
    }
}